<template>
  <div class="box1">
    <h1>我是day11第一个组件</h1>
    <h2>{{ this.$store.state.sum }}</h2>
    <h2>{{ $store.state.sum }}</h2>
    <button @click="sumBtn(1)">操作mutations中funSum让sum+1</button>
    <button @click="sumMyBtn(5)">操作actions中mySum让2秒后sum+5</button>
    <h1>{{ $store.getters.getSum }}</h1>
    <h2>{{ $store.state.userDate.userName }}</h2>
  </div>
</template>

<script>
export default {
    name:"MyDay11",
    data() {
        return {
            
        }
    },
    created(){
      console.log(this.$store);
    },
    methods:{
      sumBtn(user){
        this.$store.commit("funSum",user)
      },
      sumMyBtn(user){
        this.$store.dispatch("mySum",user)
      }
    }
}
</script>

<style scoped>
.box1 {
  border: 5px solid red;
  height: 500px;
}
</style>